using AutoMapper;
using Medical.Api.Read.Application.Command.BasicManagement.DeviceClassificationDictionaryCommand;
using Medical.Api.Read.Application.Command.BasicManagement.DeviceDictionaryCommand;
using Medical.Api.Read.Application.Command.BasicManagement.ShelfDictionaryCommand;
using Medical.Api.Read.Dto.BasicManagement.DeviceClassificationDictionaryDto;
using Medical.Api.Read.Dto.BasicManagement.DeviceDictionaryDto;
using Medical.Api.Read.Dto.BasicManagement.ShelfDictionaryDto;
using Medical.Domain.BasicManagement;

namespace Medical.Api.Read.AutoMapper
{
    /// <summary>
    /// 基础管理模块AutoMapper配置类
    /// </summary>
    public class BasicManagementMapper : Profile
    {
        /// <summary>
        /// 构造函数，配置对象映射关系
        /// </summary>
        public BasicManagementMapper()
        {
            // 设备查询DTO映射到命令
            CreateMap<QueryEquipmentDto, QueryEquipmentCommand>()
                .ForMember(dest => dest.QueryDto, opt => opt.MapFrom(src => src));

            // 货架查询DTO映射到命令
            CreateMap<QueryShelvesDto, QueryShelvesCommand>()
                .ForMember(dest => dest.QueryDto, opt => opt.MapFrom(src => src));

            // 添加器械分类到树状结构DTO的映射
            CreateMap<ApparatusType, ApparatusTypeTreeDto>()
                .ForMember(dest => dest.Children, opt => opt.Ignore()); // Children属性需要额外处理

            // 器械查询DTO映射到命令
            CreateMap<QueryApparatusDto, QueryApparatusCommand>()
                .ForMember(dest => dest.QueryDto, opt => opt.MapFrom(src => src));
        }
    }
}
